-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] [4.0] iOS Plugins #41230
[iOS] [4.0] iOS Plugins #41230
Conversation
a450ee6
to
a8dc521
Compare
Added a iOS template for plugins, which also could work as simple example. |
a8dc521
to
7f41129
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Retested with every module being rebuilt with new |
73271ff
to
f96dddb
Compare
cc @BastiaanOlij since this may affect how ARKit function is provided. |
Is there any ARKit test project for |
265aa8d
to
5eef519
Compare
naithar I believe what you have done so far is amazing. My humble request from you is that please consider making an example function which takes a parameter from gdscript side and emit an example signal in your plugin template if you can find some spare time. It would be very useful for guys like me =) Anyway, you have my gratitude, keep up your good work! |
@tolgakaranlik for now you can probably look at |
5eef519
to
1aa8f35
Compare
1aa8f35
to
6bc4a93
Compare
Well it could come as editor (?) plugin in case user doesn't need this feature, but I'm not really sure how it would work for now. |
Needs a rebase, otherwise I guess we could merge the current state already and build upon it if further changes are needed? |
Moved previously builtin modules 'GameCenter', 'AppStore', 'iCloud' to separate modules to be represented as plugin. Modified 'ARKit' and 'Camera' to not be builtin into engine and work as plugin. Changed platform code so it's not affected by the move. Modified Xcode project file to remove parameters that doesn't make any effect. Added basic '.gdip' plugin config file.
e69ee49
to
eb2bc22
Compare
Rebased.
Yeah, I think so. Moving modules to separate repo could be done in next PRs. |
Added plugin configuration. Export options now use plugins that could be enabled/disabled. Plugin changes are observed at runtime.
Plugins can use 'binary_name.a' or 'binary_name.release.a' and 'binary_name.debug.a' for plugin library.
eb2bc22
to
1f2f477
Compare
Thanks a ton for your work! |
A little suggestion: Take the Game Center plugin for example func _init() -> void: func _ready() -> void: The results is That's caused by the _init is happened before the godot_ios_plugins_initialize called. |
@alexzheng this two branches should probably allow this. But they require testing. |
I have tested in 3.2.1 rc 1 output in Xcode: My steps: it show the above error. The process is not very straightforward and I'm not sure if my steps is correct. So I did the above steps again from the source code of 3.2.4 rc1, it can run without error. |
RC1 doesn't have changes from https://github.com/naithar/godot/tree/fix/ios-plugin-initialization in it and it wouldn't until it's tested.
Without example I cannot reproduce this. With the code that you've provided earlier there are no errors:
|
I made modification in RC1 with your committed code, just move godot_ios_plugins_initialize from set_main_loop to start |
I can't reproduce your |
That's my custom gdscript class, it can run in RC1 class_name GameCenter var _GameCenter = null func _init() -> void: When it run in your branch: |
After change class_name GameCenter to class_name MyGameCenter, your branch works, and it output: |
Didn't you say that Also |
Yes, I did not notice my class name is the same as the native class in RC1. However it can works in RC1, only has the error that the Plugin GameCenter is not available in _init. |
That's because in RC1 |
Yes, I can understand, in RC1, the GDscript file that defined the class GameCenter is loaded before the plugin is registered. |
Implements godotengine/godot-proposals#1185 for
master
branch.Godot iOS Plugin template
Since this plugin implementation directly uses Godot's source headers it's important to use correct compilation flags.
This PR allows iOS project to load plugins at runtime.
This would allow developers to work on platform functionality (like Facebook Auth, AdMob and other platform specific modules) without requiring to rebuild an engine to embed it into application.
Godot's iOS binary would probably be needed to be supplied like Androids' AAR library is.Compiling plugins without Godot's iOS binary actually works fine, only headers are required, but correct compilation flags should be used.Plugins is also more portable, even than
GDNative
which requires additional setup for same functionality.Plugin also produces smaller binary size for same code - ~800KB for GameCenter plugin vs ~4MB for GameCenter in
GDNative
asframework
or ~800 KB for module + ~3MB forGDNative
itself as dependency.Also plugins can work with current module system, it's just makes things a lot easier for iOS. So it should be possible to migrate some parts of this to Godot 3.
iOS Plugin is basically a
.gdip
(like.gdap
for Android) configuration file with static library (which is linked to Godot's binary) and dependencies bundled with it..gdip
file format allows to specify dependency libraries, frameworks and resource files as well asplist
values and system capabilities. Dependencies as well as binary itself could use absolute and relative path.Plugin files should be placed in
ios/plugins
folder or it's child folder.Supports multiple target binaries.
Some parts for implementation was taken from Android's plugin system. Such as configuration file parsing, configuration observer.
Plugins configuration syntax
Example
Having project structure like this:
Enabled this export options in editor:
dymmy.cpp
file in Xcode project looks like this when exporting multiple plugins.This gives developer access to
GameCenter
,InAppStore
,iCloud
and other functionality for iOS that previously required rebuilding an engine to be enabled or disabled.Obj-C interaction
Modifying template likes this:
Results in this:
So direct communication with ObjC is not a problem.
Signals integration